package scheduler

import (
	"d-blog/service"
	"github.com/sirupsen/logrus"
)
import "github.com/robfig/cron"

// 添加一个定时任务
func addCronFunc(c *cron.Cron, sepc string, cmd func()) {
	err := c.AddFunc(sepc, cmd)
	if err != nil {
		logrus.Error(err)
	}
}
func Start() {
	c := cron.New()

	// Generate RSS
	addCronFunc(c, "@every 3m", func() {
		service.TipService.DownloadSinaImages()
		service.TipService.CollectData("123431231321431234")
	})

	// Generate sitemap
	/*	addCronFunc(c, "0 0 4 ? * *", func() {
		sitemap.Generate()
	})*/

	c.Start()
}
